# Maintainer: Newbyte <newbie13xd@gmail.com>
# Kernel config based on: arch/arm/configs/qcom_defconfig

_flavor="postmarketos-qcom-msm8226"
pkgname=linux-$_flavor
pkgver=6.9.1
pkgrel=1
_tag="v${pkgver/_/-}-msm8226"
pkgdesc="Mainline kernel fork for Qualcomm APQ8026/MSM8226/MSM8926 devices"
arch="armv7"
_carch="arm"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
"
makedepends="
	bison
	findutils
	flex
	gmp-dev
	mpc1-dev
	mpfr-dev
	openssl-dev
	perl
	postmarketos-installkernel
"

# Source
source="
	linux-$_tag.tar.gz::https://github.com/msm8226-mainline/linux/archive/refs/tags/$_tag.tar.gz
	config-$_flavor.armv7
	"
builddir="$srcdir/linux-${_tag#v}"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$CARCH" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION=$((pkgrel + 1 ))
}

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
20bece90edcb5a389fe6e01cf7565228731f5e96ab33178f386e155c42bfa1e26ba49b386abb05c971586e23fa901397d830f8265ffa9025f4785332af082827  linux-v6.9.1-msm8226.tar.gz
b17389f54804e32e5d82a274fe0cc001ba3984b5077d0ea5b8e19805e1723575e271c5dbce248ee6833aed1ad20c55370377ff24f31ea4985967cbe4b2b8d5a2  config-postmarketos-qcom-msm8226.armv7
"
